package com.chenfeng.ego.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chenfeng.ego.commons.pojo.EasyUIDataGrid;
import com.chenfeng.ego.commons.pojo.EgoResult;
import com.chenfeng.ego.pojo.TbContent;
import com.chenfeng.ego.service.TbContentService;

@Controller
public class TbContentController
{
	@Resource
	TbContentService contentService;
	@RequestMapping("content/query/list")
	@ResponseBody
	//后台内容管理列表查询
	public EasyUIDataGrid showContent(long categoryId,int page,int rows)
	{
		return this.contentService.showContentByMany(categoryId, page, rows);
	}
	//后台内容添加
	@RequestMapping("content/save")
	@ResponseBody
	public EgoResult inserContent(TbContent content)
	{
		EgoResult ego = new EgoResult();
		try
		{
			//插入操作
			int result = this.contentService.insertContentByContent(content);
			if(result>0)
			{
				ego.setStatus(200);
			}else
			{
				ego.setStatus(400);
			}
		} catch (Exception e)
		{
			ego.setStatus(400);
			e.printStackTrace();
		}
		return ego;
	}
}
